<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>登录</title>
  <link href="./dmo/css/login.css" rel="stylesheet">
</head>

<script src="./dmo/js/jquery-3.7.0.js"></script>

<body>
  <div class="container">
    <h1>登录</h1>
    <!-- <form> -->
      <!-- <div class="input-external-box"> -->

      <label class="describe-text">用户名</label>

      <input id="parameter" class="username" type="text" placeholder="Enter Username" required>

      <label class="describe-text">密码</label>

      <input id="password" type="password" placeholder="Enter Password" required>
      

      <!-- </div> -->
      <button class="submit-button" id="login">登录</button>
    <!-- </form> -->
    <a href="./register.html"><span id="resiger" style="margin-right: 190px;">注册</span></a>
    <a href="./reset_register.html"><span id="forget">忘记密码</span></a>
    </script>
  </div>

  <!--登录 login-->
  <script>
    var base_url = "http://127.0.0.1:8080/user";
    // alert("请求发送");
    $("#login").on("click", function (e) {
      // GET请求的后端接口
      var url = base_url + "/login/"
      // 获取用户输入的表单数据
      var parameter = document.getElementById("parameter").value;
      var password = document.getElementById("password").value;
      // 存储数据
      localStorage.setItem("parameter",parameter);
      localStorage.setItem("password",password);


      $.ajax({
        type: "post",    //请求方式
        async: true,    //是否异步
        url: url,
        data: { 
          "parameter": parameter, 
          "password": password 
        },    //请求参数  token
        success: function (data) {
          alert(data.msg);
          // 保存token
          localStorage.setItem("token",data.data);
          // 重定向到登陆界面 
          window.location.href = "./enterbangdan.html";
        }
      });
    })
  </script>
</body>

</html>

<!-- <div class="col-sm-6">
  <div class="thumbnail">
    <img id="imgurl-'+productId+'" src="..." alt="...">
    <div class="caption"><h3 id="goodsname-'+productId+'">
    <h3></h3>
    <p id="avg">'+'平均评分数：'+score+'</p>
    <p><a href="#" id="btn-'+productId+'" class="btn btn-primary" role="button">进入详情</a> 
    </p>
  </div>
</div>
</div> -->